# from prompt_toolkit import prompt


# # Key bindings.
# kb = KeyBindings()


# @kb.add("c-c")
# def _(event):
#     "Quit when control-c is pressed."
#     event.app.exit()


# def sample_prompt(prompt_str="prompt_string", welcome_str="Welcome %s to use the program."):
#     text = prompt(f'{prompt_str}: ')
#     print(f'{welcome_str}' % text)


# if __name__ == "__main__":
#     sample_prompt()



from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout import Layout
from prompt_toolkit.widgets import Box, Frame, TextArea
from prompt_toolkit.keys import KEY_ALIASES, Keys

class CMDApplication:

    # Layout for displaying hello world.
    # (The frame creates the border, the box takes care of the margin/padding.)
    root_container = Box(
        Frame(
            TextArea(
                text="Hello world!\nPress control-c to quit.",
                width=40,
                height=10,
            )
        ),
    )
    layout = Layout(container=root_container)

    # Key bindings.
    kb = KeyBindings()

    @staticmethod
    @kb.add("c-c")
    def _(event):
        "Quit when control-c is pressed."
        event.app.exit()

    def __init__(self):
        # Build a main application object.
        self.application = Application(layout=self.layout, key_bindings=self.kb, full_screen=True)



if __name__ == "__main__":
    app = CMDApplication()
    app.application.run()

    
    # def my_key_binding(event):
    #     "Quit when control-c is pressed."
    #     event.app.exit()

    # # app.kb.add(Keys.ControlC, my_key_binding)